package com.jvm123.blog.dao;

import com.jvm123.blog.entity.Term;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
 * @author yawn http://jvm123.com
 * 2019/10/22 13:51
 */
public interface TermRepos extends CrudRepository<Term, Long> {

    List<Term> findByPostIdAndTaxonomy(long postId, String taxonomy);

    List<Term> findByPostId(long postId);

    List<Term> findAllByTaxonomy(String taxonomy);

    @Query(value = "select post_id from jv_v_category_tags where slug=? and taxonomy=?", nativeQuery = true)
    List<Long> findPostIdBySlugAndTaxonomy(String slug, String taxonomy);

    List<Term> findAllBySlug(String slug);

    Term findFirstBySlug(String slug);
}

